package client

import "net"

//读取browser过来的数据
type browser struct {
	conn net.Conn
	er   chan bool
	writ chan bool
	recv chan []byte
	send chan []byte
}

/**
 * @Description: 读取browser过来的数据
 * @receiver b browser
 */
func (b *browser) read() {
	for {
		var recv []byte = make([]byte, 10240)
		n, err := b.conn.Read(recv)
		if err != nil {
			b.writ <- true
			b.er <- true
			break
		}
		b.recv <- recv[:n]

	}
}

func (b *browser) write() {
	for {
		var send []byte = make([]byte, 10240)
		select {
		case send = <-b.send:
			b.conn.Write(send)
		case <-b.writ:
			break
		}
	}
}
